﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>



<asp:Content ID="Content2" ContentPlaceHolderID="LeftContent" runat="server">
    <h2><%: ViewData["Message"] %></h2>
    
    <fieldset><legend>发布心情&nbsp;&nbsp;&nbsp;<a href="<%=Url.Action("ShowFeelingList","Feeling") %>">查看所有心情</a></legend>
    
    <p>限定字数140</p>
    <textarea name="content" id="feelcontent" rows="5" cols="30"></textarea>
    <p>还有多少<a id="leftcontent">140</a>字</p>
    <p><input id="feel" name="feel" type="text" /></p>
    <p><a id="addfeeling">发布</a></p>
    
    </fieldset>

    <p>
    <select class="recommendtype">
    <option value="samemajor">同专业</option>
    <option value="address">同乡</option>
    <option value="university">全校</option>
    </select>&nbsp;&nbsp;
    <a data="false" id="oppgender">异性</a>&nbsp;&nbsp;
    <a data="true" id="descending">倒序</a></p>
   <%Html.RenderAction("RecommendPart", "Home", new { currentpage = 1, type = "university", isOppGender = false, isDescending = true });%>

   <p><a href="<%=Url.Action("ShowFriendList","Relation",new{currentpage=1}) %>">查看所有好友</a></p>
   <p><a href="<%=Url.Action("ShowRequestFromOthers","Relation") %>">查看好友邀请</a></p>
   <p><a href="<%=Url.Action("ShowFeedBack","Relation") %>">查看发出邀请</a></p>
   <p><a href="<%=Url.Action("ShowFocusList","Relation",new{currentpage=1}) %>">查看关注好友</a></p>
     <h2><a class="addlover">邀请情侣</a></h2>
  <h2><a class="closelover">关闭情侣空间</a></h2>

  <h2><a class="invitefriend">邀请好友加入</a></h2>



</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript" src="../../Content/Js/Ajax.js">
        
    </script>
    <script type="text/javascript" src="../../Content/ImportJs/jquery.ui.core.js"></script>
    <script type="text/javascript" src="../../Content/ImportJs/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="../../Content/ImportJs/jquery.ui.dialog.js"></script>
    
    

    <script type="text/javascript">
        $(document).ready(function () {

            $('.invitefriend').click(function () {


                $.ajax({
                    type: 'POST',
                    url: "http://" + window.location.host + "/Relation/CreateRequestFriend",

                    success: function (data) {
                        alert(data);
                        $("<p><a>http://" + window.location.host + data + "</a></p>").appendTo($('body'));
                    },
                    error: function () {
                        alert('posterror');
                    }

                });
            });


            $('#addfeeling').click(function () {

                if ($('#feelcontent').val().length > 140)
                    return;
                var _content = encodeURI($('#feelcontent').val());

                var _feel = encodeURI($('#feel').val());

                $.ajax({
                    type: 'POST',
                    url: "http://" + window.location.host + "/Feeling/AddFeeling",
                    data: { content: _content, feel: _feel },
                    success: function (data) {
                        alert(data);
                    },
                    error: function () {
                        alert('posterror');
                    }
                });
            });


            $('#feelcontent').keyup(function () {
                var left = 140 - $('#feelcontent').val().length;
                $('#leftcontent').text(left);
            });



            $('.recommendtype').change(function () {
                var _type = $(this).val();
                var _oppgender = $('#oppgender').attr('data');
                var _descending = $('#descending').attr('data');
                var _currentpage = 1;
                AjaxRecommendList(_currentpage, _type, _oppgender, _descending);

            });

            $('#oppgender').click(function () {
                var _type = $('.recommendtype').val();
                $('#oppgender').attr("data", ($('#oppgender').attr('data')) == true ? false : true);
                var _oppgender = $('#oppgender').attr('data');
                var _descending = $('#descending').attr('data');
                var _currentpage = 1;
                AjaxRecommendList(_currentpage, _type, _oppgender, _descending);
            });

            $('#descending').click(function () {
                var _type = $('.recommendtype').val();
                $('#descending').attr("data", ($('#descending').attr('data')) == true ? false : true);
                var _oppgender = $('#oppgender').attr('data');
                var _descending = $('#descending').attr('data');
                var _currentpage = 1;
                AjaxRecommendList(_currentpage, _type, _oppgender, _descending);
            });



            function AjaxRecommendList(_currentpage, _type, _oppgender, _descending) {
                $.ajax({
                    type: 'POST',
                    url: "http://" + window.location.host + "/Json/RecommendJson",
                    data: { currentpage: _currentpage, type: _type, isOppGender: _oppgender, isDescending: _descending },
                    success: function (data) {
                        for (i = 0; i < data.length; i++) {
                            var _imagepath = data[i].ImagePath;
                            var _truename = data[i].TrueName;
                            var _address = data[i].Address;
                            var _uniaddress = data[i].UniAddress;
                            var _gender = data[i].Gender;
                            var _majorclass = data[i].MajorClass;
                            var _schoolyear = data[i].SchoolYear;
                            var _hobbies = data[i].Hobbies;
                            var _userid = data[i].UserId;
                            alert(_imagepath + _truename + _address + _uniaddress + _gender + _majorclass + _schoolyear + _hobbies + _userid);
                            ///change the UI
                        }
                        
                    },
                    error: function () {
                        alert('posterror');
                    }
                });

            }

        });

       
    </script>
</asp:Content>